Repository navigation
fix: give one next action when a confirmation token is rejected - #253
Merged
Merged
Conversation
The rejection text interpolated check.remedy, which says to call the tool again *without* `confirm`. That is right for a failure that hands nothing back, and wrong here: every rejection that reaches this branch has just issued a fresh token, named in the very next sentence. A caller that follows the remedy discards a usable token and spends another preview. The remedy stays in `confirm_error` as the diagnosis. The text now gives the single next action, worded the way the plain preview words it. The token also moves to the end of the sentence, which is the property that makes it liftable. A reader clipping the trailing word or the final backticked span gets the token; prose after it defeats both, and unwrap() strips punctuation, not a clause. Measured across both texts and four clipping strategies, all eight now apply; with the warning after the token, two of four failed on the rejection path. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
bardesss
added a commit
that referenced
this pull request
Nov 6, 2026
The rejection text interpolated check.remedy, which says to call the tool again *without* `confirm`. That is right for a failure that hands nothing back, and wrong here: every rejection that reaches this branch has just issued a fresh token, named in the very next sentence. A caller that follows the remedy discards a usable token and spends another preview. The remedy stays in `confirm_error` as the diagnosis. The text now gives the single next action, worded the way the plain preview words it. The token also moves to the end of the sentence, which is the property that makes it liftable. A reader clipping the trailing word or the final backticked span gets the token; prose after it defeats both, and unwrap() strips punctuation, not a clause. Measured across both texts and four clipping strategies, all eight now apply; with the warning after the token, two of four failed on the rejection path. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Raised during the review of #249 and left out of it, since #249 was already doing one thing well.
When a presented token is rejected for
expired,mismatchormalformed, the handler issues a fresh one and returns it. The text it returns reads:Two different next actions in one paragraph.
check.remedyis right for a failure that hands nothing back —usedthrows, and it is the one rejection that deliberately does not reissue — but every failure that reaches this branch has just minted a token, named one sentence later. A caller that follows the remedy throws away a good token and spends another preview.Before #249 the trailing sentence pointed at
confirm_token, which a text-only client could not see, so the remedy was the only reachable instruction and the conflict was latent. Making the token visible surfaced it.Fix
check.remedycomes out of the text and stays inconfirm_error, so the diagnosis is still there for anything that reads the structured half. The text gives one instruction, worded the way the plain preview words it:The word order is load-bearing
My first attempt put the warning after the token (
set to \v1.…` — not the token that was just rejected`). A probe caught that this breaks the thing both this and #249 exist for. Clipping the token out of the sentence four plausible ways:unwrap()from #250 strips punctuation, not a trailing clause. #249's preview text already ended with the token, which is why it survived all four. Ending the rejection the same way is what makes the two paths behave alike, so there is now a test pinning that invariant for both rather than a convention nobody wrote down.All eight combinations (two texts, four clips) apply, with
apply()firing once each.Tests
test/writeTool.test.ts, both written before the change and watched to fail:confirm", whileconfirm_errorstill doesThe three gates
What was exercised
Harness tests, plus the before-and-after clipping measurement above against the real
registerWriteToolandConfirmTokens. Not run against a live stack. The change is two template strings and the removal of one interpolation; no response field changes, so it is afix:.🤖 Generated with Claude Code